home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1998 July / MacFormat CD-ROM MF65 (Future Publishing, Ltd.)(July 1998).iso / Shareware Plus / Development / SERIALNUMBER BUNDLE / CSerialNumLib.h next >
Encoding:
Text File  |  1998-03-27  |  5.2 KB  |  141 lines  |  [TEXT/CWIE]

  1. //----------------------------------------------------------------------------
  2. //    Filename:    CSerialNumLib.h
  3. //    Copyright © 1998 Wilfried Bernard. All rights reserved.
  4. //
  5. //  See the file "McSerialNumber README" for more details and the licensing 
  6. //    agreement, etc.  
  7. //
  8. //    Description:    Header to implement encoding/decoding of serial numbers
  9.  
  10. //    ATTENTION!
  11. //     ----------
  12. //     If you incorporate the 68k-library in your application
  13. //     allways use the following switches for the Metrowerks IDE:
  14. //     68k Processor:     check 4 Byte Ints and 8 Byte Doubles ON
  15. //                    check Far Data, Far Method Table and Far String Consts ON
  16. //
  17. //    Send your questions/bugs and comments to:
  18. //    <e-mail>         mcwareusa@aol.com or mcwareusa@kagi.com
  19. //    <www-page>        http://members.aol.com/mcwareusa
  20. //
  21. //----------------------------------------------------------------------------
  22. // Revision History:
  23. // Mar, 28 1998 - 1.0 oSWSt first public release
  24. //----------------------------------------------------------------------------
  25.  
  26. #pragma once
  27.  
  28.  
  29. class CSerialNumLib
  30. {
  31.     public:
  32.     // All Public Functions
  33.     
  34. // MANIPULATOR
  35. //-------------                     
  36. //----------------------------------------------------------------------------
  37. //    PARAMETER:    ConstStr31Param first_name
  38. //                ConstStr31Param last_name
  39. //            
  40. //    RESULT:        long long        test_number
  41. //    
  42. //    Entering the customer first and a last name creates a 64 bit test number
  43. //    which is NOT the real serial number. 
  44. //    check with the real serialnumber AND your master code with CheckSumTest()
  45. //----------------------------------------------------------------------------
  46.     static    long long    CalcNameCode        (ConstStr31Param    inFirstNameStr,    
  47.                                              ConstStr63Param    inLastNameStr);
  48.  
  49.  
  50. //----------------------------------------------------------------------------
  51. //    PARAMETER:    long long        test_number
  52. //                long long        serial_number
  53. //                long long        master_key
  54. //            
  55. //    RESULT:        Boolean            test_valid
  56. //    
  57. //    Checks validity of the real serialnumber by testing against your master code
  58. //    and the names test number (CalcNameCode)
  59. //----------------------------------------------------------------------------
  60.     static    Boolean        CheckSumTest        (long long             inNameCode, 
  61.                                              long long             inSerialNumber, 
  62.                                              long long             inMasterKey );
  63.     
  64.     
  65. //----------------------------------------------------------------------------
  66. //    PARAMETER:    ConstStr31Param    serial_number_string
  67. //                long long        serial_number
  68. //            
  69. //    RESULT:        Boolean            test_valid
  70. //    
  71. //    Converts the serial number string into a real serialnumber,
  72. //    strips all non-hexadecimal characters. Reports FALSE if serialnumber
  73. //    string is invalid else TRUE
  74. //----------------------------------------------------------------------------
  75.     static    Boolean        StripSerialNumber    (ConstStr31Param    inSerNrString,    
  76.                                              long long&            outSum);
  77.  
  78. // CONVERTER
  79. //-----------                         
  80. //----------------------------------------------------------------------------
  81. //    PARAMETER:    IN:        StringPtr        serial_number_string (p-string)
  82. //                OUT:    long long        serial_number
  83. //            
  84. //    RESULT:        none
  85. //    
  86. //    converts the serial number pascal-string into the 64 bit number,
  87. //----------------------------------------------------------------------------
  88.     static    void        PStrToLLong            (StringPtr            inPStr,            
  89.                                              long long&            outSum);
  90.                                              
  91. //----------------------------------------------------------------------------
  92. //    PARAMETER:    IN:        StringPtr        serial_number_string (c-string)
  93. //                OUT:    long long        serial_number
  94. //            
  95. //    RESULT:        none
  96. //    
  97. //    Converts the serial number c-string into the 64 bit number,
  98. //----------------------------------------------------------------------------
  99.     static    void        ANSIStrToLLong        (char*                 inCStr,         
  100.                                              long long&            outVal);
  101.  
  102.                                              
  103. //----------------------------------------------------------------------------
  104. //    PARAMETER:    OUT:     ConstStr31Param    serial_number_string    (allocate memory!)
  105. //                IN:        long long        IN serial_number
  106. //            
  107. //    RESULT:        none
  108. //    
  109. //    Converts 64 bit number into a serial number pascal-string
  110. //----------------------------------------------------------------------------
  111.     static    void        LLongToPStr            (ConstStr31Param    outPStr,        
  112.                                              long long            inSum);
  113.                                              
  114. //----------------------------------------------------------------------------
  115. //    PARAMETER:    OUT:    ConstStr31Param    serial_number_string    (allocate memory!)
  116. //                IN:        long long        serial_number
  117. //            
  118. //    RESULT:    none
  119. //    
  120. //    Converts 64 bit number into a serial number c-string
  121. //----------------------------------------------------------------------------
  122.     static    void        LLongToANSIStr        (ConstStr31Param    outCStr,
  123.                                              long long             inVal);
  124.  
  125. //----------------------------------------------------------------------------
  126. //    INPUT:    long long        IN master_key_number (if you pass <nil> an internal 
  127. //                                                  check will take place)
  128. //            
  129. //    RESULT:    long long        OUT master_code
  130. //    
  131. //    returns the real master code number from the library
  132. //
  133. //    ATTENTION:
  134. //    First set your master code as default in the McSerialnumber application
  135. //    preferences dialog BEFORE you create the library otherwise the resulting
  136. //    mastercode may/can be zero (always test your library before implementation)
  137. //----------------------------------------------------------------------------
  138.     static    long long    GetMasterCode        (long long             inMasterKey);
  139.     
  140. };
  141.